<?php
require 'PHPMailer/class.phpmailer.php';

function invitationMail($mailDest, $nomDest, $nomEmetteur) {
	//require './PHPMailer/class.phpmailer.php';
	$mail = new PHPMailer();
	//$mail->PluginDir = './PHPMailer'; // relative path to the folder where PHPMailer's files are located
	$mail->IsSMTP();
	$mail->Port = 465;
	$mail->Host = 'smtp.gmail.com'; // "ssl://smtp.gmail.com" didn't worked
	$mail->IsHTML(true); // if you are going to send HTML formatted emails
	$mail->Mailer = 'smtp';
	$mail->SMTPSecure = 'ssl';
	$mail->CharSet="utf-8";
	
	$mail->SMTPAuth = true;
	$mail->Username = "itin.sharein@gmail.com";
	$mail->Password = "itin2012";

	$mail->SingleTo = true; // if you want to send mail to the users individually so that no recipients can see that who has got the same email.

	$mail->From = "itin.sharein@gmail.com";
	$mail->FromName = "ShareIn";

	$mail->addAddress($mailDest, $nomDest);
	//$mail->addAddress("user.2@gmail.com","User 2");

	//$mail->addCC("user.3@ymail.com","User 3");
	//$mail->addBCC("user.4@in.com","User 4");

	$mail->Subject = $nomEmetteur." t'invite à rejoindre ShareIn";
	$mail->Body = "Salut,<br /><br />".$nomEmetteur." est inscrit sur la plateforme ShareIn et t'invite à t'inscrire afin d'échanger avec elle et les autres membres sur des sujets que tu vas adorer !<br /> Rejoins nous vite en cliquant sur ce lien <a href='http://212.73.217.202:7777/ShareIn/index-register.html'>http://212.73.217.202:7777/ShareIn/index-register.html</a><br /><br />A tout de suite !<br /><br />L'équipe ShareIn";

	if(!$mail->Send())
		echo "Message was not sent <br />PHP Mailer Error: " . $mail->ErrorInfo;
	else
		return 1;
}

function adminMail($mailDest, $objet, $contain) {
	//require './PHPMailer/class.phpmailer.php';
	$mail = new PHPMailer();
	//$mail->PluginDir = './PHPMailer'; // relative path to the folder where PHPMailer's files are located
	$mail->IsSMTP();
	$mail->Port = 465;
	$mail->Host = 'smtp.gmail.com'; // "ssl://smtp.gmail.com" didn't worked
	$mail->IsHTML(true); // if you are going to send HTML formatted emails
	$mail->Mailer = 'smtp';
	$mail->SMTPSecure = 'ssl';
	$mail->CharSet="utf-8";
	
	$mail->SMTPAuth = true;
	$mail->Username = "itin.sharein@gmail.com";
	$mail->Password = "itin2012";

	$mail->SingleTo = true; // if you want to send mail to the users individually so that no recipients can see that who has got the same email.

	$mail->From = "itin.sharein@gmail.com";
	$mail->FromName = "ShareIn";

	$mail->addAddress($mailDest, "");
	//$mail->addAddress("user.2@gmail.com","User 2");

	//$mail->addCC("user.3@ymail.com","User 3");
	//$mail->addBCC("user.4@in.com","User 4");

	$mail->Subject = $objet;
	$mail->Body = $contain;
	
	if(!$mail->Send())
		echo "Message was not sent <br />PHP Mailer Error: " . $mail->ErrorInfo;
	else
		return 1;
}

function registrationMail($mailDest, $nomDest, $login, $mdp) {
	//require './PHPMailer/class.phpmailer.php';
	$mail = new PHPMailer();
	//$mail->PluginDir = './PHPMailer'; // relative path to the folder where PHPMailer's files are located
	$mail->IsSMTP();
	$mail->Port = 465;
	$mail->Host = 'smtp.gmail.com'; // "ssl://smtp.gmail.com" didn't worked
	$mail->IsHTML(true); // if you are going to send HTML formatted emails
	$mail->Mailer = 'smtp';
	$mail->SMTPSecure = 'ssl';
	$mail->CharSet="utf-8";

	$mail->SMTPAuth = true;
	$mail->Username = "itin.sharein@gmail.com";
	$mail->Password = "itin2012";

	$mail->SingleTo = true; // if you want to send mail to the users individually so that no recipients can see that who has got the same email.

	$mail->From = "itin.sharein@gmail.com";
	$mail->FromName = "ShareIn";

	$mail->addAddress($mailDest, $nomDest);
	//$mail->addAddress("user.2@gmail.com","User 2");

	//$mail->addCC("user.3@ymail.com","User 3");
	//$mail->addBCC("user.4@in.com","User 4");

	$mail->Subject = "Bienvenue sur ShareIn";
	$mail->Body = "Bienvenue ".$nomDest." et merci de vous être inscrit(e) sur ShareIn,<br /><br />Vous allez dès à présent pouvoir participer, argumenter et échanger sur ShareIn avec tous les membres.<br /><br />Voici vos identifiants :<br />Login : ".$login."<br />Mot de passe : ".$mdp."<br /><br />A tout de suite sur <a href='http://212.73.217.202:7777/ShareIn/'>ShareIn</a> !<br /><br />L'équipe ShareIn";

	if(!$mail->Send())
		echo $mail->ErrorInfo;
	else
		return 1;
}
?>